﻿@using Microsoft.AspNetCore.Identity
@using Zhaoxi.IdentitySample.Web.Entites
@inject SignInManager<User> _signInManager

@{
    var lastname = User.Claims.SingleOrDefault(claim => claim.Type == "lastname")?.Value;
}

<ul class="navbar-nav">
    @if (_signInManager.IsSignedIn(User))
    {
        <li class="nav-item">
            <a class="nav-link text-dark" asp-controller="Home" asp-action="Index"
               title="Welcome">
                欢迎 @lastname!
            </a>
        </li>
        <li class="nav-item">
            <a class="nav-link text-dark" asp-controller="Account"
               asp-action="Logout">登出</a>
        </li>
    }
    else
    {
        <li class="nav-item">
            <a class="nav-link text-dark" asp-controller="Account"
               asp-action="Login">登录</a>
        </li>
        <li class="nav-item">
            <a class="nav-link text-dark" asp-controller="Account"
               asp-action="Register">注册</a>
        </li>
    }
</ul>